package com.chinacoal.microservice.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.chinacoal.microservice.pojo.CcmsSmartleasingNotice;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author zhuliang
 * @version V1.0
 * @Description: 通知单-mybatis-plus接口类
 * @date 2020-11-27 9：37
 */
public interface CcmsSmartleasingNoticeMapper extends BaseMapper<CcmsSmartleasingNotice> {

    /**
     * @Description: 房间费用信息id查询详细信息
     * @author zhuliang
     * @date 2020/11/27 11:42
     */
    CcmsSmartleasingNotice getNoticeByExpenseManagId(@Param("fkExpenseManagId") String fkExpenseManagId,
                                                     @Param("fkPropertyCompanyId") String fkPropertyCompanyId,
                                                     @Param("fkAdministrativeOfficeId") String fkAdministrativeOfficeId);

    /**
     * @Description: 根据合同id查询信息
     * @author zhuliang
     * @date 2020/11/27 18:37
     */
    List<CcmsSmartleasingNotice> getInformationByContractId();

    /**
     * @Description: 批量添加
     * @author zhuliang
     * @date 2020/11/27 19:29
     */
    void batchAdd(List<CcmsSmartleasingNotice> noticeList);

    /**
     * @Description: 根据费用信息id和房间id查询通知单信息
     * @author zhuliang
     * @date 2020/12/4 14:08
     */
    CcmsSmartleasingNotice getAllByExpenseManagId(@Param("fkRoomId") String fkRoomId,
                                                  @Param("fkExpenseManagId") String fkExpenseManagId);

    /**
     * @Description: 根据费用id得到开票需要的信息
     * @author zhuliang
     * @date 2020/12/7 14:47
     */
    CcmsSmartleasingNotice getBillingInformation(@Param("fkExpenseManagId") String fkExpenseManagId);

    /**
     * @Description: 根据费用信息id查询通知单信息
     * @author zhuliang
     * @date 2020/12/10 16:07
     */
    CcmsSmartleasingNotice getByExpenseManagId(@Param("fkExpenseManagId") String fkExpenseManagId);

    /**
     * @Description: 根据房间id查询当月的通知单
     * @author zhuliang
     * @date 2020/12/17 19:48
     */
    CcmsSmartleasingNotice getNoticeByRoomId(@Param("pkRoomId") String pkRoomId);

    /**
     * @Description: 根据房间id查询所有未抄表的通知单
     * @author zhuliang
     * @date 2020/12/17 19:48
     */
    List<CcmsSmartleasingNotice> getNoticeListByRoomId(@Param("pkRoomId") String pkRoomId);

    /**
     * @Description: 清除水费数据
     * @author zhuliang
     * @date 2020/12/22 15:25
     */
    void clearByWater(@Param("pkNoticeId") String pkNoticeId);

    /**
     * @Description: 清除电费数据
     * @author zhuliang
     * @date 2020/12/22 15:25
     */
    void clearByElectricity(@Param("pkNoticeId") String pkNoticeId);

    /**
     * @Description: 清除煤气费数据
     * @author zhuliang
     * @date 2020/12/22 15:25
     */
    void clearByGas(@Param("pkNoticeId") String pkNoticeId);

    /**
     * @Description: 微信端-根据费用id查询通知单信息
     * @author zhuliang
     * @date 2020/12/23 16:06
     */
    CcmsSmartleasingNotice getNoticeByWechat(@Param("fkExpenseManagId") String fkExpenseManagId);

    /**
     * @Description: 获取支付金额
     * @author zhuliang
     * @date 2020/12/25 16:29
     */
    BigDecimal getTotalAmount(@Param("pkNoticeId") String pkNoticeId);

    /**
     * @Description: 写入支付订单号
     * @author zhuliang
     * @date 2020/12/25 15:29
     */
    void updateOrderNumber(@Param("lastUpdateDate") Date lastUpdateDate,
                           @Param("lastUpdatedBy")Integer lastUpdatedBy,
                           @Param("pkNoticeId") String pkNoticeId,
                           @Param("orderNumber") String orderNumber);

    /**
     * @Description: 查询是否有重复订单号
     * @author zhuliang
     * @date 2020/12/25 15:49
     */
    String judgmentRepeat(@Param("orderNumber") String orderNumber);

    /**
     * @Description: 支付成功修改费用表和通知单表信息
     * @author zhuliang
     * @date 2020/12/25 16:07
     */
    void updateByPaySuccess(@Param("lastUpdateDate") Date lastUpdateDate,
                            @Param("lastUpdatedBy") Integer lastUpdatedBy,
                            @Param("orderNumber") String orderNumber,
                            @Param("paymentTime") Date paymentTime,
                            @Param("paidInExpenses") BigDecimal paidInExpenses,
                            @Param("wxOrderNumber") String wxOrderNumber);

    /**
     * @Description: 查询支付状态
     * @author zhuliang
     * @date 2020/12/25 18:09
     */
    String getPayStatus(@Param("pkNoticeId") String pkNoticeId,
                        @Param("orderNumber") String orderNumber);

    /**
     * @Description: 根据开票信息id查询费用信息
     * @author zhuliang
     * @date 2021/2/1 17:49
     */
    CcmsSmartleasingNotice getNoticeByInvoiceRecordId(@Param("fkInvoiceRecordId") String fkInvoiceRecordId);

    /**
     * @Description: 查询缴费的费用单月份
     * @author zhuliang
     * @date 2021/2/4 14:01
     */
    Date checkMonthPayment(@Param("orderNumber") String orderNumber);

    /**
     * 将电梯费置为空
     * @param pkNoticeId
     */
    void updateElevatorFeeToNull(@Param("pkNoticeId") String pkNoticeId);

    /**
     * 将卫生费置为空
     * @param pkNoticeId
     */
    void updateSanitationFeeToNull(@Param("pkNoticeId") String pkNoticeId);

    /**
     * 将本体维修基金置为空
     * @param pkNoticeId
     */
    void updateMaintenanceFundToNull(@Param("pkNoticeId") String pkNoticeId);

    /**
     * 将电视费/煤保置为空
     * @param pkNoticeId
     */
    void updateGasInsuranceToNull(@Param("pkNoticeId") String pkNoticeId);

    /**
     * 审核前查询notice表（需要额外查询本体维修金）
     * @param pkExpenseManagId
     * @param property
     * @param managementOffice
     * @return
     */
    CcmsSmartleasingNotice getNewNoticeByExpenseManagId(@Param("fkExpenseManagId") String pkExpenseManagId,
                                                        @Param("fkPropertyCompanyId") String property,
                                                        @Param("fkAdministrativeOfficeId") String managementOffice);
}
